<?php
// +----------------------------------------------------------------------
// | Yzncms [ 御宅男工作室 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2018 http://yzncms.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | fastadmin: https://www.fastadmin.net/
// +----------------------------------------------------------------------

namespace app\admin\command;


use think\console\Command;
use think\console\Input;
use think\console\input\Option;
use think\console\Output;

use Workerman\Connection\TcpConnection;
use Workerman\Worker;

class Item extends Command
{
    /**
     * @var \think\Request Request 实例
     */
    protected $request;

    protected function configure()
    {
        $this->setName('item')
            ->setDescription('Command Close');
    }

    /**
     * 命令行安装
     */
    protected function execute(Input $input, Output $output)
    {
        $http_worker = new Worker("http://127.0.0.1:2345");
        $http_worker->count = 4;

        $http_worker->onMessage = function(TcpConnection $connection, \Workerman\Protocols\Http\Request $request)
        {
            // 向浏览器发送hello world
            $connection->send('hello world');
        };
        Worker::runAll();

    }
}
